package com.asiainfo.complier.conf;

import com.asiainfo.complier.helper.FileHelper;
import java.io.File;
import java.util.Properties;
import javax.swing.JFrame;

public class SysSetting {

	public static String JDK_CLASS_PATH = "";
	public static String JDK_PATH = "";
	public static String OUTPUT_PATH = "";
	public static String JAVA_VERSION = "1.5";
	private static String jdk_file = "jdk.properties";
	public static String SHOW_LINE = "true";
	public static String HIGHTER_LINE = "true";
	public static String HIGHTER_CARET = "true";
	public static String CUSTOMER_CLASS_PATH = "";

	public static void initSetting() {
		Properties prop = FileHelper.loadProperties(System
				.getProperty("user.home") + File.separator + jdk_file);
		if (prop != null) {
			JDK_CLASS_PATH = prop.getProperty("jdk_class_path");
			CUSTOMER_CLASS_PATH = prop.getProperty("customer_class_path");
			JDK_PATH = prop.getProperty("jdk_path");
			OUTPUT_PATH = prop.getProperty("output_path");
			JAVA_VERSION = prop.getProperty("java_version");

			SHOW_LINE = prop.getProperty("show_line") != null ? "true"
					: "false";
			HIGHTER_LINE = prop.getProperty("highter_line") != null ? "true"
					: "false";
			HIGHTER_CARET = prop.getProperty("highter_caret") != null ? "true"
					: "false";
		}
	}

	public static JFrame MAIN_Frame;

	public static void saveSetting() {
		Properties prop = FileHelper.loadProperties(System
				.getProperty("user.home") + File.separator + jdk_file);

		prop.setProperty("jdk_class_path", JDK_CLASS_PATH);
		prop.setProperty("jdk_path", JDK_PATH);
		prop.setProperty("output_path", OUTPUT_PATH);
		prop.setProperty("java_version", JAVA_VERSION);

		prop.setProperty("show_line", SHOW_LINE);
		prop.setProperty("highter_line", HIGHTER_LINE);
		prop.setProperty("highter_caret", HIGHTER_CARET);
		prop.setProperty("customer_class_path", CUSTOMER_CLASS_PATH);

		FileHelper.saveProperties(System.getProperty("user.home")
				+ File.separator + jdk_file, prop);
	}

	private SysSetting() {
	}
}
